Line 1 : using System;// \r\n
Line 2 : using System.IO;
Line 3 : using System.Text;
Line 4 : using System.Text.RegularExpressions;
Line 5 : 
Line 6 : namespace Example
Line 7 : {
Line 8 :     class Program
Line 9 :     {
Line 10 :         static void Main()
Line 11 :         {
Line 12 :             StreamWriter writer = new StreamWriter("..\\..\\Alabala.cs", false, Encoding.GetEncoding("UTF-8"));
Line 13 :             //ako e false - nov fail, ako e true - Append(dobavq kym faila bez da go iztriva)
Line 14 :             //StreamWriter writer = new StreamWriter("..\\..\\Alabala.cs",false, Encoding.GetEncoding("windows-1251"));
Line 15 :             using (writer)
Line 16 :             {
Line 17 : 
Line 18 :                 StreamReader reader = new StreamReader(@"..\..\Program.cs", Encoding.GetEncoding("UTF-8"));
Line 19 :                 using (reader)
Line 20 :                 {
Line 21 :                     int linenumber = 0;
Line 22 :                     string line = reader.ReadLine();
Line 23 :                     while (line != null)
Line 24 :                     {
Line 25 :                         linenumber++;
Line 26 :                         writer.WriteLine("Line {0} : {1}", linenumber, line);
Line 27 :                         line = reader.ReadLine();
Line 28 :                     }
Line 29 :                 }
Line 30 :                 Console.WriteLine("READY!");
Line 31 :             }
Line 32 :             Console.Read();
Line 33 :             StreamReader reader2 = new StreamReader(@"..\..\Program.cs");
Line 34 :             using (reader2)
Line 35 :             {
Line 36 :                 StreamReader reader1 = new StreamReader("..\\..\\Alabala.cs");
Line 37 :                 using (reader1)
Line 38 :                 {
Line 39 :                     StreamWriter writer1 = new StreamWriter("..\\..\\Alabala1.cs");
Line 40 :                     using (writer1)
Line 41 :                     {
Line 42 :                         int linenumber = 0;
Line 43 :                         string line = reader1.ReadLine();
Line 44 :                         string linetosplit = line.ToString();
Line 45 :                         string linereader2 = reader2.ReadLine();
Line 46 :                         while (line != null)
Line 47 :                         {
Line 48 : 
Line 49 :                             linenumber++;
Line 50 :                             bool linetosplitbool = linetosplit.Contains("Line " + linenumber + " : " + linereader2);
Line 51 :                             string equal1 = ("Line " + linenumber + " : " + linereader2);
Line 52 :                             bool lineequals = String.Equals(linetosplit, equal1);
Line 53 :                             bool equal = equal1 == linetosplit;
Line 54 :                             string linenumbertostring = linenumber.ToString();
Line 55 :                             string lineexample = ("Line " + linenumbertostring + " : ");
Line 56 :                             writer1.WriteLine(line);
Line 57 :                             writer1.Flush();//tova e da prenebregne buferiraneto(kogato zavurshi izvejdaneto nacqlo togava zapisva
Line 58 :                             //faila), tuka pishe red po red vuv faila
Line 59 :                             Console.WriteLine(line);
Line 60 :                             try
Line 61 :                             {
Line 62 :                                 line = reader1.ReadLine();
Line 63 :                                 //if (line != null)
Line 64 :                                 //{
Line 65 :                                 linetosplit = line.ToString();
Line 66 :                                 linereader2 = reader2.ReadLine();
Line 67 :                                 //}
Line 68 :                             }
Line 69 :                             catch (NullReferenceException ex) // catch(IOException ex) // za cqloto InputOutputExceptions
Line 70 :                             {
Line 71 :                                 Console.WriteLine("NullReferenceException - Veche e null linetosplit : " + ex.Message);
Line 72 :                             }
Line 73 :                         }
Line 74 :                     }
Line 75 :                 }
Line 76 :             }
Line 77 :             try
Line 78 :             {
Line 79 :                 StreamReader reader1 = new StreamReader("..\\..\\NotExcistingFile.txt");
Line 80 :             }
Line 81 :             catch (System.NullReferenceException exc)
Line 82 :             {
Line 83 :                 Console.WriteLine("{0}", exc.Message);
Line 84 : 
Line 85 :             }
Line 86 :             catch (System.IO.FileNotFoundException)
Line 87 :             {
Line 88 :                 Console.WriteLine("FILE NOT FOUND!");
Line 89 :             }
Line 90 :             catch
Line 91 :             {
Line 92 :                 Console.WriteLine("Fatal error occured!");
Line 93 :             }
Line 94 : 
Line 95 :             StreamReader reader3 = new StreamReader(@"..\..\Program.cs");
Line 96 :             using (reader3)
Line 97 :             {
Line 98 :                 int count = 0;
Line 99 :                 string text = reader3.ReadToEnd();
Line 100 :                 int index = text.IndexOf("foundme", 0);
Line 101 :                 while (index!=-1)
Line 102 :                 {
Line 103 :                     count++;
Line 104 :                     index = text.IndexOf("foundme", index + 1);
Line 105 :                 }
Line 106 :                 Console.WriteLine(count);
Line 107 :             }
Line 108 :         }
Line 109 :     }
Line 110 : }
